<%@ page contentType="text/html; charset=utf-8" import="java.net.InetAddress,common.*,java.sql.*,db.*,java.util.*"%>
<%
String ent_id= (String)session.getAttribute("ent_id");
String search_gubun= request.getParameter("search_gubun")==null?"":request.getParameter("search_gubun");
String search_word = CommonUtil.nvl(request.getParameter("search_word"));
String search_flag =CommonUtil.nvl(request.getParameter("search_flag"));

String start_page = CommonUtil.nvl(request.getParameter("start_page"),"0");
String page_row =CommonUtil.nvl(request.getParameter("page_row"),"5");

Connection con=null;
ArrayList list =null;
ArrayList list2 =null;
HashMap userMap = new HashMap();
try {
	
	con = (new CommonConnect()).getConnection_ds1();
	String[] param=null;
	String[] param2=null;
	String queryStr ="";
	String queryStr2 = "";
//메인페이지의 리스트 내역을 가져온다.
	param= new String[6];
	param[0] = ent_id;
	param[1] = search_word;
	param[2] = search_gubun;
	param[3] = search_flag;
	param[4] = start_page;
	param[5] = page_row;
	
	queryStr = "call stu_edu1401List_mobile(?,?,?,?,?,?)";	
	list = DAO.select(con,queryStr,param);
	
	
	
	//System.out.println(list);
	
} catch (Exception e) {
	e.printStackTrace();
}finally {
	  try{
		  if (con!=null) con.close();
	  }catch(Exception ee){}
}
%>
<jsp:include page="/mobile/common/head.jsp"></jsp:include>

<script>

var start_page = <%=start_page%>;
var page_row = <%=page_row%>;
var ent_id = "<%=ent_id%>";
var search_word = "<%=search_word%>";


function lastPostFunc() 
{ 
	start_page = start_page + <%=page_row%>;
	
	$('div#lastPostsLoader').html('<img src="loadinfo_net.gif">'); 
    $.post("course_scroll.jsp?action=getLastPosts&lastID=" + $(".wrdLatest:last").attr("id")+"&start_page=" +start_page+"&page_row=" +page_row+"&ent_id=" +ent_id+"&search_word=" +search_word,    
	
    function(data){ 
        if (data != "") {
        	//alert($.trim(data));
        	if($.trim(data) == "null"){
        		alert('자료가 더이상 존재하지 않습니다.');
        		//document.getElementById("more_btn").display = "none";
        		$("#more_btn_c").children().eq(0).remove();
        	}else{
        		//$(".wrdLatest:last").after(data);  
        		
        		$("#data-page").append(data);
        		$("#data-page").listview('refresh');
        	}
        } 
        $('div#lastPostsLoader').empty(); 
    }); 
};





/*
$(window).scroll(function(){ 
        if  ($(window).scrollTop() == $(document).height() - $(window).height()){ 
          lastPostFunc(); 
        } 
});
*/

function go_class(id,ccate_nm){
	frm = document.mainform;
	frm.action = "/mobile/course_view.jsp";
	frm.poi_cd.value = id;
	frm.poi_nm.value = ccate_nm;
	frm.target="_self";
	frm.submit();
}
</script>

<body>
<div data-role="page" id="page_main" >  
      
        <div data-role="header"   data-backbtn="true">  
        <h1>과정 목록</h1>   
        </div>  
  
        <div class="wrdLatest" id=1 name=1>
        <div data-role="content" >  

<form name="mainform"  method="post">
<input type="hidden" name="search_gubun" value="">
<input type="hidden" name="search_word"  value="">
<input type="hidden" name="search_flag" value="">
<input type="hidden" name="start_page" value="">
<input type="hidden" name="page_row" value="">

<input type="hidden" name="poi_cd" value="">
<input type="hidden" name="poi_nm" value="">
</form>	    
    	
    	        
            <ul id="data-page" data-role="listview"  data-dividertheme="b">  <!-- data-filter="true" data-inset="true" --> 
                                        
                     
                    <%		
                    for (int j=0; list!=null && list.size() > j; j++){
						HashMap map2 = (HashMap)list.get(j);
						
					%>
					<li><a href="javascript:go_class('<%= (String)map2.get("poi_cd")%>','<%= (String)map2.get("poi_nm") %>')"><%= (String)map2.get("poi_nm")%></a></li> 
					<%				
									}				
							
					%>    
                    
                       
            </ul>  
         </div> 
         </div>
         
         
         <div data-role="content" id="more_btn_c">  
            <ul data-role="listview"  data-dividertheme="b">  <!-- data-filter="true" data-inset="true" --> 
                    <li id="more_btn"><a href="javascript:lastPostFunc()">더보기</a></li>   
            </ul>  
         </div> 
         
         
         
         <jsp:include page="/mobile/common/footer.jsp"></jsp:include> 
          
        <div id="lastPostsLoader">  
</div> 


</body>
</html>
